﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using Hangjing.SQLServerDAL;
using Hangjing.Common;
using Hangjing.WebCommon;
using Hangjing.Model;

/// <summary>
/// 提现记录
/// </summary>
public partial class shop_OrderList_cachoutlist : System.Web.UI.Page
{
    private string SqlWhere
    {
        get
        {
            object o = ViewState["SqlWhere"];
            return (o == null) ? string.Empty : o.ToString();
        }
        set
        {
            ViewState["SqlWhere"] = value;
        }
    }

    /// <summary>
    /// 商家编号
    /// </summary>
    private int tid
    {
        get
        {
            object o = ViewState["tid"];
            return (o == null) ? 0 : Convert.ToInt32(o);
        }
        set
        {
            ViewState["tid"] = value;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        UserHelp.IsLogin_Togo(Request.Url.PathAndQuery);

        if (!this.Page.IsPostBack)
        {
            tid = UserHelp.GetUser_Togo().Unid;
            SqlWhere = " shopid = " + tid + "";
            BindData();
        }
    }

    shopcashout dal = new shopcashout();
    protected void BindData()
    {
        this.AspNetPager1.RecordCount = dal.GetCount(SqlWhere);
        this.rptOrderList.DataSource = dal.GetList(AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex, SqlWhere, "cid", 1);
        this.rptOrderList.DataBind();
        NoRecord();
    }

    private void NoRecord()
    {
        if (rptOrderList.Items.Count == 0)
        {
            noRecord.Style.Add(HtmlTextWriterStyle.Display, "block");
        }
        else
        {
            noRecord.Style.Add(HtmlTextWriterStyle.Display, "none");
        }
    }

    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        BindData();
    }

    protected void rptOrderList_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "view")
        {
            Response.Redirect("OrderDetail.aspx=" + Convert.ToInt32(e.CommandArgument));
        }
    }

    protected void btSearch_Click(object sender, EventArgs s)
    {
        SqlWhere = "shopid = " + tid + "";
        if (starttime.Value != "")
        {
            SqlWhere += "  and  starttime >= '" + WebUtility.InputText(this.starttime.Value.Trim()) + "' ";
        }
        if (enttime.Value != "")
        {
            SqlWhere += " and starttime <= '" + WebUtility.InputText(this.enttime.Value.Trim()) + " 23:59:59' ";
        }
        if (this.ddlstate.SelectedValue != "-1")
        {
            SqlWhere = SqlWhere + " and state=" + ddlstate.SelectedValue + "";
        }

        BindData();
    }

}
